#include "OldGuyDeath.h"

OldGuyDeath::OldGuyDeath(QGraphicsScene *scene)
{
    root = QFileInfo(__FILE__).absolutePath();
    for(int j=0;j<6;j++){
        deathlist.append(QPixmap(root + "/res/old_death_frame" + (QString)(i + 1) + ".png"));
    }
    i=0;
    this->setVisible(false);
    scene->addItem(this);
}

QRectF OldGuyDeath::boundingRect() const{
    return QRectF(-deathlist[0].width()*0.5-20,-deathlist[0].height()*0.5-20,deathlist[0].width()*0.5-20,deathlist[0].height()*0.5-20);
}

void OldGuyDeath::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->drawPixmap(-deathlist[0].width() * 0.5, -deathlist[0].height() * 0.5, deathlist[i]);
}

void OldGuyDeath::updateDeathAnimation()
{
    this->setVisible(true);
    i = (i+1)%6;
    this->update();
}
